package com.llh.designpatterns.factory.simplefactory.demo01;

/**
 * <h2>简单工厂</h2>
 * <p>通常情况下，会把创建类实例的方法设置为静态方法，称之为静态工厂。</p>
 * <p>CreatedAt: 2019-11-25 23:28</p>
 * <p><a href="mailto:forever2y_y@163.com">SendMailToMe</a></p>
 *
 * @author llh
 */
public class SimpleFactoryCar {

    public Car createCar(String carType) {
        System.out.println("使用简单工厂模式");

        if (carType.equals("Truck")) {
            return new Truck();
        } else if (carType.equals("sports")) {
            return new SportsCar();
        } else {
            return null;
        }
    }
}
